﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using System.Diagnostics;

namespace WindowsFormsApplication3
{
    class DElete
    {
        public void deletefromAFFCLIENTVIAclientID(int clientid)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "DELETE FROM ClientAffected where clientId='" + clientid + "';";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Connection = myConnection;
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
        public void deletefromAFFCLIENTVIAPOID(int POID)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "DELETE FROM ClientAffected where POID='" + POID + "';";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Connection = myConnection;
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
        public void setInactiveClient(int clientId)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "UPDATE status='false' FROM client where clientId='" + clientId + "';";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Connection = myConnection;
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
        public void setActiveClient(int clientId)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "UPDATE status='true' FROM client where clientId='" + clientId + "';";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Connection = myConnection;
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
  
     public void SetPOinactive(int POid)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "Update set status='false' FROM PurchaseOrder where POID='" + POid + "';";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Connection = myConnection;
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
     public void SetPOActive(int POid)
     {

         try
         {
             MySqlConnection myConnection;
             string server;
             string database;
             string uid;
             string password;
             //MySqlDataReader dataReader;
             string query = "Update set status='true' FROM PurchaseOrder where POID='" + POid + "';";
             server = "localhost";
             database = "travel_cmp_db";
             uid = "root";
             password = "p@ssword";
             string connectionString;
             connectionString = "SERVER=" + server + ";" + "DATABASE=" +
             database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

             myConnection = new MySqlConnection(connectionString);
             myConnection.Open();
             MySqlCommand cmd = new MySqlCommand();
             cmd.CommandText = query;
             cmd.Connection = myConnection;
             cmd.ExecuteNonQuery();
             myConnection.Close();

         }
         catch (Exception e)
         {
             Debug.WriteLine(e.ToString());
         }
     }
        public void deletedeadline(int deadlineid)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "DELETE FROM deadline where deadline='" + deadlineid+ "';";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Connection = myConnection;
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
        public void setDeadlineInactivate(int deadlineid)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "Update Set deadlinestatus='false' FROM deadline where deadline='" + deadlineid + "';";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Connection = myConnection;
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
        public void setDeadlineActivate(int deadlineid)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "Update Set deadlinestatus='true' FROM deadline where deadline='" + deadlineid + "';";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Connection = myConnection;
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
    }
}
